<script setup lang='ts'>
import HomePanel from './HomePanel.vue'
import useStore from '@/store';
import { ref } from 'vue';
const imgRef = ref<HTMLImageElement | null>(null)
// onMounted(()=> {
//   const { stop } = useIntersectionObserver(imgRef.value, ([{isIntersecting}]) => {
//   // console.log('可视区域');
//   // console.log(isIntersecting);
//   // console.log(imgRef.value?.dataset);
  
//   if(isIntersecting){
//     if(imgRef.value) {
//       imgRef.value.src = imgRef.value.dataset.set || ''
//     }
//   }
// })
// // setTimeout(()=>{
// //   stop()
// // },2000)
// })
const { home } = useStore()
home.getHomeNewList()
</script>

<template>
    <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱" >
        <template #right>
          <xtx-more to="/">查看更多</xtx-more>
        </template>
          <ul class="goods-list">
        <li v-for="ele in home.newsList" :key="ele.id">
          <RouterLink to="/">
            <img
              v-Lazy="ele.picture"
              alt=""
            />
            <p class="name ellipsis">{{ ele.name }}}</p>
            <p class="price">&yen;{{ ele.price }}</p>
          </RouterLink>
        </li>
      </ul>
      </HomePanel>
</template>

<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>